﻿// --------------------------------------------------------------------------------------------------------------------- 
// <copyright file="InferredLink.cs" company="Scrum for Team System">
//   None
// </copyright>
// <summary>
//   Defines the LinkPath type.
// </summary>
// ---------------------------------------------------------------------------------------------------------------------

namespace ScrumForTeamSystem.EventService.AggregationService.DataObjects
{
    using System.Xml.Serialization;

    using Infrastructure;

    /// <summary>
    /// Work item link path type.
    /// </summary>
    public enum LinkPath
    {
        /// <summary>
        /// The iternation path.
        /// </summary>
        IterationPath = 0,

        /// <summary>
        /// The area path.
        /// </summary>
        AreaPath = 1
    }

    /// <summary>
    /// The path match type.
    /// </summary>
    public enum PathMatch
    {
        /// <summary>
        /// Match a partial path. 
        /// </summary>
        Partial = 0,

        /// <summary>
        /// Match the complete path.
        /// </summary>
        Complete = 1
    }

    /// <summary>
    /// Defines the InferredLink type.
    /// </summary>
    public class InferredLink
    {
        /// <summary>
        /// Gets or sets MatchDepth.
        /// </summary>
        /// <value>
        /// The match depth.
        /// </value>
        [XmlAttribute(AttributeName = "depth")]
        public int MatchDepth
        {
            get;
            set;
        }

        /// <summary>
        /// Gets or sets MatchType.
        /// </summary>
        /// <value>
        /// The match type.
        /// </value>
        [XmlAttribute(AttributeName = "type")]
        public PathMatch MatchType
        {
            get;
            set;
        }

        /// <summary>
        /// Gets or sets PathType.
        /// </summary>
        /// <value>
        /// The path type.
        /// </value>
        [XmlAttribute(AttributeName = "path")]
        public LinkPath PathType
        {
            get;
            set;
        }

        /// <summary>
        /// Gets the name of the path field.
        /// </summary>
        /// <value>The name of the path field.</value>
        public string PathFieldName
        {
            get
            {
                return this.PathType == LinkPath.AreaPath
                               ? ConstantStrings.WorkItemAreaPathCoreField
                               : ConstantStrings.WorkItemIterationPathCoreField;
            }
        }
    }
}